package com.codedancer.campus.manager.handler.impl.lostFoundItem;

import static com.codedancer.campus.enums.SystemMessageType.LOST_FOUND_ITEM_EXAMINE;

import cn.hutool.core.bean.BeanUtil;
import com.codedancer.campus.common.utils.UUIDGenerator;
import com.codedancer.campus.enums.SystemMessageType;
import com.codedancer.campus.manager.handler.SystemMessageHandler;
import com.codedancer.campus.manager.service.model.SystemMessageMqParamModel;
import com.codedancer.campus.mapper.SystemMessageMapper;
import com.codedancer.campus.po.SystemMessage;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Data
@Component
@Slf4j
public class LostFoundItemExamineSystemMessageHandler implements SystemMessageHandler {

    private final SystemMessageType messageType = LOST_FOUND_ITEM_EXAMINE;

    @Autowired
    private SystemMessageMapper systemMessageMapper;

    /**
     * 保存系统消息
     *
     * @param systemMessageMqParamModel
     */
    @Override
    public void saveSystemMessage(SystemMessageMqParamModel systemMessageMqParamModel) {
        SystemMessage systemMessage = BeanUtil.copyProperties(systemMessageMqParamModel,
            SystemMessage.class);
        systemMessage.setUuid(UUIDGenerator.getUUID());
        log.info("系统消息信息：{}", systemMessageMqParamModel);
        systemMessageMapper.insert(systemMessage);
    }

    @Override
    public SystemMessageType getSystemMessageType() {
        return messageType;
    }
}
